﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model.Po;
using nERP.Model.Fin;
using nERP.Model.So;

namespace nERP.Model.Bas
{
    /// <summary>
    /// 结算账户
    /// </summary>
	[Table("SettlementAccount")]
    [SoftKey(nameof(SettlementAccount.Code))]
    [Display(Name = "_Model.SettlementAccount")]
    public class SettlementAccount : BasePoco,IPersistPoco,ITenant
    {
        [Display(Name = "_Model._SettlementAccount._Code")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("编号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string Code { get; set; }
        [Display(Name = "_Model._SettlementAccount._Name")]
        [StringLength(64, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("名称")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Name { get; set; }
        [Display(Name = "_Model._SettlementAccount._BeginAmount")]
        [Comment("期初金额")]
        public decimal? BeginAmount { get; set; }
        [Display(Name = "_Model._SettlementAccount._NowAmount")]
        [Comment("当前余额")]
        public decimal? NowAmount { get; set; }
        [Display(Name = "_Model._SettlementAccount._Remark")]
        [StringLength(256, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._Buy._SettlementAccount")]
        [InverseProperty("SettlementAccount")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Po.Buy.SettlementAccountId))]
        public List<Buy> Buy_SettlementAccount { get; set; }
        [Display(Name = "_Model._Sale._SettlementAccount")]
        [InverseProperty("SettlementAccount")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.So.Sale.SettlementAccountId))]
        public List<Sale> Sale_SettlementAccount { get; set; }
        [Display(Name = "_Model._Receivable._SettlementAccount")]
        [InverseProperty("SettlementAccount")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Fin.Receivable.SettlementAccountId))]
        public List<Receivable> Receivable_SettlementAccount { get; set; }
        [Display(Name = "_Model._Payment._SettlementAccount")]
        [InverseProperty("SettlementAccount")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Fin.Payment.SettlementAccountId))]
        public List<Payment> Payment_SettlementAccount { get; set; }
        [Display(Name = "_Model._OtherIncome._SettlementAccount")]
        [InverseProperty("SettlementAccount")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Fin.OtherIncome.SettlementAccountId))]
        public List<OtherIncome> OtherIncome_SettlementAccount { get; set; }
        [Display(Name = "_Model._OtherOutlay._SettlementAccount")]
        [InverseProperty("SettlementAccount")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Fin.OtherOutlay.SettlementAccountId))]
        public List<OtherOutlay> OtherOutlay_SettlementAccount { get; set; }
        [Display(Name = "_Model._SettlementAccount._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
